var users = [
  {name:"john lennon", sex: "male", phone:"123"},
  {name:"prince", sex: "male", phone:"234"},
  {name:"rihanna", sex:"female", phone:"345"},
  {name:"taylor swift", sex:"female", phone:"456"}
]

var getFemaleUserPhone = function(users){
  var phones = []
  users.forEach(function(u){
    if(u.sex === "female"){
      phones.push(u.phone)
    }
  })
  return phones
}

console.log(getFemaleUserPhone(users))

var FemaleUser = function(users){
  return users.filter(function(u){return u.sex === "female"})
}
var getPhone = function(users){
  return users.map(function(u){return u.phone})
}
console.log(FemaleUser(users))
console.log(getPhone(FemaleUser(users)))

var compose = function(f,g){
  return function(x){
    return f(g(x))
  }
}
getFemaleUserPhone = compose(getPhone,FemaleUser)
console.log(getFemaleUserPhone(users))
